package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose=new Thread("rose"){
            @Override
            public void run() {
                System.out.println(getName()+":let me go");
                for (int i=0;i<5;i++){
                    try {
                        Thread.sleep(1000);
                    }catch (InterruptedException e){
                    }
                }
                System.out.println(getName()+":啊啊啊啊啊啊啊啊AAAAAAAaaaaaa......");
                System.out.println("噗通");
            }

        };
        Thread jack=new Thread("jack"){
            @Override
            public void run() {

                while (true){
                    try {
                        System.out.println(getName()+":you jump! i jump!");
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        rose.start();
        jack.setDaemon(true);
        jack.start();
        /*
        gc垃圾回收器就是守护线程
        游戏中的通讯就是守护线程
         */
        System.out.println("main方法结束了");//主线程也是普通线程
    }
}
